import { loggerProvider } from '@app/common/constants';
import { RequestInterceptor } from '@app/common/interceptors/request.interceptor';
import { GraphqlModule as GraphqlLibModule } from '@app/graphql';
import { RestfulModule } from '@app/restful';
import { Logger, Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { APP_INTERCEPTOR } from '@nestjs/core';
import configuration from 'config/config.default';

@Module({
  imports: [
    ConfigModule.forRoot({
      load: [configuration],
      isGlobal: true,
    }),
    GraphqlLibModule,
    RestfulModule,
  ],
  controllers: [],
  providers: [
    {
      provide: loggerProvider,
      useFactory: () => {
        return new Logger();
      },
    },
    {
      provide: APP_INTERCEPTOR,
      useClass: RequestInterceptor,
    },
  ],
})
export class AppModule {}
